package com.usian.mapper;

import com.usian.message.Message;
import com.usian.user.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MessageMapper {
    @Select("select * from message where (send_id = #{sendId} and accept_id = #{acceptId}) or (send_id = #{acceptId} and accept_id = #{sendId})")
    List<Message> selectMessageList(Integer acceptId,Integer sendId);
    @Select("select * from message where  accept_id = #{userid}")
    List<Message> find(Integer userid);
    @Select("SELECT * FROM message WHERE send_id = #{sendId} ORDER BY id DESC LIMIT 1")
    Message findend(Integer sendId);
    @Select("SELECT * FROM tb_user WHERE id = #{sendId}")
    User selectUserOne(Integer sendId);
    @Insert("insert into message(send_id,accept_id,message,send_date) values(#{sendId},#{acceptId},#{message},#{sendDate})")
    Integer insert(Message message1);
    @Select("select * from message where (send_id = #{sendId} and accept_id = #{acceptId}) or (send_id = #{acceptId} and accept_id = #{sendId}) ORDER BY id DESC LIMIT 1")
    Message findea(Integer sendId, Integer acceptId);
}
